package com.yukefms.fms_core;

import com.yukefms.engine.SimpleFMSEngine;
import com.yukefms.engine.interfaces.FMSEngine;
import com.yukefms.message.KafkaConfig;
import com.yukefms.message.MessageConsumer;
import com.yukefms.message.MessageProducer;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ConfigurableApplicationContext;

import java.util.concurrent.TimeUnit;
//(scanBasePackages="com.yukefms.message")
@SpringBootApplication(scanBasePackages={"com.yukefms.message","com.yukefms.engine","com.yukefms.fms_core"})
public class FmsCoreApplication {
    static ConfigurableApplicationContext Context ;
    public static void main(String[] args) throws Exception {

        Context = SpringApplication.run(FmsCoreApplication.class, args);
        FMSEngine engine = Context.getBean(SimpleFMSEngine.class) ;
        engine.doInit();
        engine.startup();
////        MessageConsumer consumer = new MessageConsumer() ;
//        MessageProducer producer = Context.getBean(MessageProducer.class) ;
//        new Thread(consumer).start() ;
//        for (int i=0; i<40; i++) {
//            producer.send(KafkaConfig.TOPIC_TEST, "content_"+i) ;
//        }
//        TimeUnit.SECONDS.sleep(30);
//        consumer.stop();


    }
    public static void start() {
        // start up engine, including:
        //   1. set the rule
        //   2. initialize all stuffs
        //   3. start consumer
        //   4. do the reaction
        //
        // start CONSUMER
        //
        //





    }

}
